package com.bjpowernode.services.impls;

import com.bjpowernode.constants.Constant;
import com.bjpowernode.entities.TActivity;
import com.bjpowernode.mappers.TActivityMapper;
import com.bjpowernode.querys.ActivityQuery;
import com.bjpowernode.querys.BaseQuery;
import com.bjpowernode.services.ActivityService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ActivityServiceImpl implements ActivityService {
    @Resource
    private TActivityMapper tActivityMapper;

    @Override
    public TActivity getActivityById(Integer id) {
        return tActivityMapper.selectById(id);
    }

    @Override
    public PageInfo<TActivity> getActivityByPage(Integer current, ActivityQuery activityQuery) {
        PageHelper.startPage(current, Constant.PAGE_SIZE);
        List<TActivity> tActivityList = tActivityMapper.selectByPage(new BaseQuery(), activityQuery);
        return new PageInfo<>(tActivityList);
    }
}
